package br.pucrio.inf.aaaong.models.database.update;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;


public class UpdateQueryParamsSetter {
	private int inx = 0;
	private PreparedStatement statement;
	
	public UpdateQueryParamsSetter(PreparedStatement statement) {
		this.statement = statement;
	}
	
	public void setString(String str) throws SQLException {
		statement.setString(++inx, str);
	}
	
	public void setInt(Integer i) throws SQLException {
		inx++;
		if (i == null) {
			statement.setObject(inx, null);
		} else {
			statement.setInt(inx, i);
		}
	}
	
	public void setCalendar(Calendar calendar) throws SQLException {
		inx++;
		if (calendar == null) {
			statement.setDate(inx, null);
		} else {
			statement.setDate(inx, new java.sql.Date(calendar.getTimeInMillis()));
		}
	}
}
